package sk.benko.appsresource.client.model;

import java.util.ArrayList;
import java.util.HashMap;

import sk.benko.appsresource.client.model.result.CountObjectsResult;
import sk.benko.appsresource.client.model.result.CreateOrUpdateObjectResult;
import sk.benko.appsresource.client.model.result.GetObjectsResult;
import sk.benko.appsresource.client.model.result.GetSearchCountsResult;
import sk.benko.appsresource.client.model.result.GetSearchObjectsResult;
import sk.benko.appsresource.client.model.result.GetTreeLevelResult;
import sk.benko.appsresource.client.model.result.GetValuesResult;
import sk.benko.appsresource.client.model.result.UpdateValueResult;

import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * The asynchronous interface for calls to {@link ApplicationService}.
 *
 *
 */
public interface ApplicationServiceAsync extends ServiceAsync {
  
  /**
   * @see ApplicationService#getTreeLevel(int, int, ArrayList<TreeLevel>, 
   * TemplateAttribute)
   * @param langId
   * @param tId
   * @param path
   * @param ta
   * @param callback
   */
  void getTreeLevel(int langId, int tId, ArrayList<TreeLevel> path, 
      TemplateAttribute ta, AsyncCallback<GetTreeLevelResult> callback);
  void getTreeLevel(int langId, int tIdSource, 
      HashMap<Integer, ArrayList<AValue>> values, 
      int tId, ArrayList<TreeLevel> path, TemplateAttribute ta, 
      AsyncCallback<GetTreeLevelResult> callback);
  
  /**
   * @see ApplicationService#getObjects(int, int, ArrayList<TreeLevel>, 
   * TemplateAttribute)
   * @param langId
   * @param tId
   * @param path
   * @param ta
   * @param callback
   */
  void getObjects(int langId, int tId, ArrayList<TreeLevel> path, 
      TemplateAttribute ta, AsyncCallback<GetObjectsResult> callback);

  /**
   * @see ApplicationService#getSearchObjectCounts(int, String)
   * @param appId
   * @param searchString
   * @param callback
   */
  void getSearchObjectCounts(int appId, String searchString,
      AsyncCallback<GetSearchCountsResult> callback);
  
  /**
   * @see ApplicationService#getSearchObjects(int, String, int, int, int)
   * @param langId
   * @param searchString
   * @param tlId
   * @param from
   * @param perPage
   * @param callback
   */
  void getSearchObjects(int langId, String searchString, int tlId, int from, 
      int perPage, AsyncCallback<GetSearchObjectsResult> callback);
  
  /**
   * @see ApplicationService#getRelatedObjectCounts(int, int)
   * @param objId
   * @param rel
   * @param callback
   */
  void getRelatedObjectCounts(int objId, int rel, Template t,
      AsyncCallback<GetSearchCountsResult> callback);

  /**
   * @see ApplicationService#getRelatedObjects(int, int, int, int, int, int)
   * @param langId
   * @param objId
   * @param rel
   * @param tlId
   * @param perPage
   * @param callback
   */
  void getRelatedObjects(int langId, int objId, int rel, int tlId, int from, 
      int perPage, AsyncCallback<GetSearchObjectsResult> callback);

  /**
   * @see ApplicationService#getValues(AObject)
   * @param object
   * @param callback
   */
  void getValues(AObject object, 
      AsyncCallback<GetValuesResult> callback);

  /**
   * @see ApplicationService#createObject(AObject)
   * @param object
   * @param values
   * @param callback
   */
  void createObject(AObject object, ArrayList<AValue> values, 
      AppUser author, AsyncCallback<CreateOrUpdateObjectResult> callback);

  /**
   * @see ApplicationService#deleteObject(AObject)
   * @param object
   * @param callback
   */
  void deleteObject(AObject object, AppUser author, 
      AsyncCallback<String> callback);

  void updateValue(AValue value, AppUser author,
      AsyncCallback<UpdateValueResult> callback);

  void importObjects(Application app, Template t, String filename,
      HashMap<Integer, TemplateAttribute> map,
      HashMap<Integer, TemplateAttribute> keys, 
      boolean onlyUpdate, AppUser author,
      AsyncCallback<CountObjectsResult> callback);

  void removeDuplicates(Application app, Template t,
      HashMap<Integer, TemplateAttribute> keys, AppUser author,
      AsyncCallback<CountObjectsResult> callback);

}
